#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2025/9/16 10:28
# @Author  : Tom_zc
# @FileName: publish_community_cve.py
# @Software: PyCharm


import requests
import logging
import click

logging.basicConfig(level=logging.INFO,
                    format="%(asctime)s  %(levelname)s:%(message)s")


@click.command()
@click.option("--cve_manager_url", help="the url of cve-manager")
@click.option("--affected_tag", help='the affected tag')
@click.option("--fixed_tag", help='the affected tag')
def main(cve_manager_url, affected_tag, fixed_tag):
    json_data = {
        "org": "openUBMC",
        "affected_product": affected_tag,
        "fixed_product": fixed_tag
    }
    resp = requests.put(cve_manager_url, json=json_data, timeout=(60, 60))
    if not str(resp.status_code).startswith("20"):
        logging.error("status_code:{}, and content:{}".format(resp.status_code, resp.content.decode()))
        raise Exception("request cve error")
    exit(0)


if __name__ == '__main__':
    main()
